home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP09.ZIP / CHAP09 / PATRON / PATRON.H < prev    next >
C/C++ Source or Header  |  1993-06-07  |  7KB  |  236 lines

  1. /*
  2.  * PATRON.H
  3.  * Modifications for Chapter 9
  4.  *
  5.  * Single include file that pulls in everything needed for other source
  6.  * files in the application.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #ifndef _PATRON_H_
  19. #define _PATRON_H_
  20.  
  21. #include <windows.h>
  22.  
  23. #include <ole2.h>
  24. #include <ole2ver.h>
  25. #include <ole2ui.h>
  26. #include <bookguid.h>
  27.  
  28. extern "C"
  29.     {
  30.     #include <commdlg.h>
  31.     #include <print.h>
  32.     }
  33.  
  34. #include <classlib.h>
  35. #include "resource.h"
  36.  
  37. //Get editor window information
  38. #include "pages.h"
  39.  
  40. //PATRON.CPP:  Frame object that creates a main window
  41.  
  42. class __far CPatronFrame : public CFrame
  43.     {
  44.     private:
  45.         BOOL            m_fInitialized;     //OleInitialize worked
  46.  
  47.     protected:
  48.         //Overridable for creating a CPatronClient
  49.         virtual LPCClient CreateCClient(void);
  50.  
  51.         //CHAPTER9MOD
  52.         virtual BOOL      FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
  53.         //End CHAPTER9MOD
  54.         virtual BOOL      FRegisterAllClasses(void);
  55.         virtual UINT      CreateGizmos(void);
  56.         virtual LRESULT   OnCommand(HWND, WPARAM, LPARAM);
  57.  
  58.     public:
  59.         CPatronFrame(HINSTANCE, HINSTANCE, LPSTR, int);
  60.         virtual ~CPatronFrame(void);
  61.  
  62.         //Overrides
  63.         BOOL FInit(LPFRAMEINIT);
  64.  
  65.         virtual void     UpdateMenus(HMENU, UINT);
  66.         virtual void     UpdateGizmos(void);
  67.  
  68.     };
  69.  
  70.  
  71. typedef CPatronFrame FAR * LPCPatronFrame;
  72.  
  73.  
  74.  
  75.  
  76.  
  77. //CLIENT.CPP
  78.  
  79. /*
  80.  * The only reason we have a derived class here is to override
  81.  * CreateCDocument so we can create our own type as well as
  82.  * overriding NewDocument to perform one other piece of work once the
  83.  * document's been created.
  84.  */
  85.  
  86. class __far CPatronClient : public CClient
  87.     {
  88.     protected:
  89.         //Overridable for creating a new CDocument
  90.         virtual LPCDocument CreateCDocument();
  91.  
  92.     public:
  93.         CPatronClient(HINSTANCE);
  94.         virtual ~CPatronClient(void);
  95.     };
  96.  
  97. typedef CPatronClient FAR * LPCPatronClient;
  98.  
  99.  
  100.  
  101. //DOCUMENT.CPP
  102.  
  103. //Constant ID for the pages window that lives in a document window
  104. #define ID_PAGES            723
  105.  
  106.  
  107. class __far CPatronDoc : public CDocument
  108.     {
  109.     //These need access to FQueryPasteFromData, FPasteFromData
  110.     friend class CDropTarget;
  111.     friend class CDropSource;
  112.  
  113.     protected:
  114.         LONG            m_lVer;         //Loaded data version
  115.         LPCPages        m_pPG;          //Pages window in us.
  116.         LPSTORAGE       m_pIStorage;    //Root storage for document.
  117.         BOOL            m_fPrintSetup;  //Enable printer setup if no tenants.
  118.  
  119.         class CDropTarget FAR *m_pDropTarget;  //Registered target.
  120.  
  121.         //CHAPTER9MOD
  122.         UINT            m_cfEmbeddedObject; //Clipboard formats
  123.         UINT            m_cfObjectDescriptor;
  124.         //End CHAPTER9MOD
  125.  
  126.     protected:
  127.         virtual BOOL    FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
  128.  
  129.         BOOL            FQueryPasteFromData(LPDATAOBJECT, LPFORMATETC, LPTENANTTYPE);
  130.  
  131.         //CHAPTER9MOD
  132.         BOOL            FPasteFromData(LPDATAOBJECT, LPFORMATETC, TENANTTYPE
  133.                             , LPPATRONOBJECT, DWORD, BOOL);
  134.         //End CHAPTER9MOD
  135.  
  136.     public:
  137.         CPatronDoc(HINSTANCE);
  138.         virtual ~CPatronDoc(void);
  139.  
  140.         virtual BOOL     FInit(LPDOCUMENTINIT);
  141.         virtual void     Clear(void);
  142.  
  143.         virtual BOOL     FDirtyGet(void);
  144.         virtual void     Delete(void);
  145.         virtual BOOL     FQueryPrinterSetup(void);
  146.         virtual BOOL     FQueryObjectSelected(HMENU);
  147.  
  148.         virtual UINT     ULoad(BOOL, LPSTR);
  149.         virtual UINT     USave(UINT, LPSTR);
  150.  
  151.         virtual BOOL     Print(HWND);
  152.         virtual UINT     PrinterSetup(HWND, BOOL);
  153.  
  154.         virtual BOOL     FClip(HWND, BOOL);
  155.         virtual BOOL     FQueryPaste(void);
  156.         virtual BOOL     FPaste(HWND);
  157.         virtual BOOL     FPasteSpecial(HWND);
  158.  
  159.         virtual UINT     NewPage(void);
  160.         virtual UINT     DeletePage(void);
  161.         virtual UINT     NextPage(void);
  162.         virtual UINT     PreviousPage(void);
  163.         virtual UINT     FirstPage(void);
  164.         virtual UINT     LastPage(void);
  165.  
  166.         //CHAPTER9MOD
  167.         virtual void     Rename(LPSTR);
  168.         virtual BOOL     FInsertObject(HWND);
  169.         virtual void     ActivateObject(UINT);
  170.         //End CHAPTER9MOD
  171.  
  172.     };
  173.  
  174. typedef CPatronDoc FAR * LPCPatronDoc;
  175.  
  176.  
  177. //Drag-drop interfaces we need in the document
  178.  
  179. class __far CDropTarget : public IDropTarget
  180.     {
  181.     protected:
  182.         ULONG               m_cRef;      //Interface reference count.
  183.         LPCPatronDoc        m_pDoc;      //Back pointer to the document
  184.  
  185.         LPDATAOBJECT        m_pIDataObject;  //Data object from DragEnter
  186.         BOOL                m_fPendingRepaint;
  187.         POINTL              m_ptPick;        //Pick-up offsets
  188.         POINTL              m_ptLast;        //Last drag point
  189.         SIZEL               m_szl;           //Object size
  190.         BOOL                m_fFeedback;     //Draw feedback?
  191.         FORMATETC           m_fe;            //Real dropping format.
  192.  
  193.     public:
  194.         CDropTarget(LPCPatronDoc);
  195.         ~CDropTarget(void);
  196.  
  197.         //IDropTarget interface members
  198.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  199.         STDMETHODIMP_(ULONG) AddRef(void);
  200.         STDMETHODIMP_(ULONG) Release(void);
  201.  
  202.         STDMETHODIMP DragEnter(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
  203.         STDMETHODIMP DragOver(DWORD, POINTL, LPDWORD);
  204.         STDMETHODIMP DragLeave(void);
  205.         STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
  206.     };
  207.  
  208.  
  209. typedef CDropTarget FAR * LPCDropTarget;
  210.  
  211.  
  212. class __far CDropSource : public IDropSource
  213.     {
  214.     protected:
  215.         ULONG               m_cRef;      //Interface reference count.
  216.  
  217.     public:
  218.         CDropSource(void);
  219.         ~CDropSource(void);
  220.  
  221.         //IDropSource interface members
  222.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  223.         STDMETHODIMP_(ULONG) AddRef(void);
  224.         STDMETHODIMP_(ULONG) Release(void);
  225.  
  226.         STDMETHODIMP QueryContinueDrag(BOOL, DWORD);
  227.         STDMETHODIMP GiveFeedback(DWORD);
  228.     };
  229.  
  230.  
  231. typedef CDropSource FAR * LPCDropSource;
  232.  
  233.  
  234.  
  235. #endif //_PATRON_H_
  236.